package com.wu.foodsafetyplayer.app.fragment.main;

import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.wu.foodsafetyplayer.R;
import com.wu.foodsafetyplayer.app.dialog.LoadingUtil;
import com.wu.foodsafetyplayer.app.fragment.BaseFragment;


public class PromoteFragment extends BaseFragment implements View.OnClickListener {

    @Override
    protected int getLayoutResId() {
        return R.layout.fragment_promote;
    }

    @Override
    protected void initView() {
        super.initView();
        WebView webView = findViewById(R.id.f_promote_web);
        webView.getSettings().setJavaScriptEnabled(true);
        webView.getSettings().setAppCacheEnabled(true);
        //设置 缓存模式
        webView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
        // 开启 DOM storage API 功能
        webView.getSettings().setDomStorageEnabled(true);
        webView.setWebViewClient(new WebViewClient() {
            //覆盖shouldOverrideUrlLoading 方法
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                view.loadUrl(url);
                return true;
            }
        });
        webView.loadUrl("http://www.syxwnet.com/p/158553.html");
        webView.setWebViewClient(new WebViewClient(){
            @Override
            public void onPageFinished(WebView view, String url) {
                super.onPageFinished(view, url);
                LoadingUtil.INSTANCE.dismissLoading(getActivity());
            }
        });
        LoadingUtil.INSTANCE.showLoading(getActivity(),"加载中");
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
        }
    }
}
